﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Taobao.common;

namespace Taobao.Saver
{
    public partial class ShopManager : List<SShop>
    {

        public ShopManager()
        #region >><<
        {

        }

        public bool isDispose { get; set; }
        public void Dispose()
        {

        }
        #endregion

        #region >>CleanTimeout<<

        #endregion

        public bool getITEM(long id,out SShop item)
        #region >><<
        {
            item = this.Find(r => r.ID == id);
            bool rtn = false;
            if (item == null)
            {
                SHOP item1;
                if (Taobao.DBServer.ShopDAL.Instance.GetData(id, out item1))
                {
                    item = new SShop()
                    {
                        Shop = item1,
                    };
                    rtn = item1 != null;
                }
                else
                    throw new SaverException("Run DB error");
            }
            return rtn;
        }
        #endregion

        public bool Update(SHOP item1, SShop item2)
        #region >><<
        {
            if (DBServer.ShopDAL.Instance.Update(item1))
            {
                item2.Shop = item1;
                return true;
            }
            return false;
        }
        #endregion

        public bool Add(SHOP item1, out SShop item2)
        #region >><<
        {
            item2 = new SShop();
            if (DBServer.ShopDAL.Instance.AddNew(item1))
            {
                item2.Shop = item1;
                this.Add(item2);
                return true;
            }
            return false;
        }
        #endregion
    }
}
